package net.apexcns.core.spring;

import net.apexcns.core.spring.editor.NumberEditor;

import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeansException;
import org.springframework.beans.propertyeditors.StringArrayPropertyEditor;
import org.springframework.jdbc.core.BeanPropertyRowMapper;

public class CoreBeanPropertyRowMapper extends BeanPropertyRowMapper {
	public <T> CoreBeanPropertyRowMapper(Class<T> clazz) {
		super(clazz);
	}

	protected void initBeanWrapper(BeanWrapper bw) throws BeansException {
		bw.registerCustomEditor(String[].class,
						new StringArrayPropertyEditor());
		
		bw.registerCustomEditor(int.class, "orderAlt", new NumberEditor() {
			public void setAsText(String text) throws IllegalArgumentException {
				System.out.println("-------oooaaaaaaaaaaaaaaaaa--------------" + text);
				setValue("0");
			}
		});
		bw.registerCustomEditor(int.class, new NumberEditor() {
			public void setAsText(String text) throws IllegalArgumentException {
				System.out.println("-------aaaaaaaaaaaaaaaaa--------------" + text);
				setValue("0");
			}
		});

	}

}
